package server.business.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import server.business.mapper.PatientMapper;
import server.business.pojo.BloodSamplePatient;
import server.business.service.BloodSamplePatientService;
import server.business.mapper.BloodSamplePatientMapper;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author Galaxy
* @description 针对表【blood_sample_patient】的数据库操作Service实现
* @createDate 2022-11-08 12:46:24
*/
@Service("bloodSamplePatientService")
public class BloodSamplePatientServiceImpl extends ServiceImpl<BloodSamplePatientMapper, BloodSamplePatient>
    implements BloodSamplePatientService{

    //*************************************myq*************************start
    @Autowired
    private BloodSamplePatientMapper bloodSamplePatientMapper;


    @Override
    public Page<BloodSamplePatient> getBloodSamplePatientPage() {
        Page<BloodSamplePatient> page = new Page<>(1, 5);
        bloodSamplePatientMapper.selectPage(page, null);
        page.getRecords().forEach(System.out::println);
        long pageSize = page.getSize();
        System.out.println(pageSize);
        System.out.println(page.getTotal());

        return page;
    }

    @Override
    public IPage<BloodSamplePatient> getPage(int currentPage, int pageSize, BloodSamplePatient bloodSamplePatient, String startTime, String endTime) {
        LambdaQueryWrapper<BloodSamplePatient> queryWrapper= new LambdaQueryWrapper<BloodSamplePatient>();
        queryWrapper
                .eq(Strings.isNotBlank(bloodSamplePatient.getBloodSampleNumber()),BloodSamplePatient::getBloodSampleNumber,bloodSamplePatient.getBloodSampleNumber())
                .ge(startTime!=null,BloodSamplePatient::getDrawTime,startTime)
                .le(endTime!=null,BloodSamplePatient::getDrawTime,endTime);
        IPage<BloodSamplePatient> page = new Page<>(currentPage,pageSize);
        bloodSamplePatientMapper.selectPage(page,queryWrapper);
        return page;
    }
    //*************************************myq*************************end
}




